package com.lizhi.yun.webservice.config;

import com.lizhi.yun.webservice.WebService;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

/**
 * @Author: lizhi
 * @Description:
 * @Date: create in 2020/12/15 13:18
 */
@Configuration
public class Cxfonfig {

    @Autowired(required = false)
    private Bus bus;

    @Autowired(required = false)
    private WebService webService;

    /**
     * 自定义服务在ip:port/upperlimb/**路径下面
     * @return
     */
//    @Bean
//    public ServletRegistrationBean getDispatcherServlet() {
//        return new ServletRegistrationBean(new CXFServlet() , "/upperlimb/*");
//    }

    /**
     * 默认服务在ip:port/services/**路径下面
     * @return
     */
    @Bean
    public Endpoint endpointWebService(){
        EndpointImpl endpoint = new EndpointImpl(bus, webService);
        endpoint.publish("/WebService/upperlimb/message");
        return endpoint;
    }
}
